﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using yq.ControllerBase;
using System.Web.Mvc;


namespace yq.Controller.Home
{
    /// <summary>
    /// 异常处理
    /// </summary>
    [HandleError]
    public class ErrorController : BaseController
    {
        /// <summary>
        /// 错误页面 
        /// </summary>
        /// <param name="errorGuid"></param>
        /// <returns></returns>
        [NoPurviewFilter()]
        public ActionResult Error500(string errorGuid = "")
        {
            //将异常修改为207
            Response.StatusCode = 207;
            string errorText = "";
            if (string.IsNullOrEmpty(errorGuid) || TempData[errorGuid] == null)
            {
                errorText = "未定义错误原因,请在方法上定义错误提示";
            }
            else
            {
                errorText = TempData[errorGuid].ToString();
                TempData[errorGuid] = errorText;
            }

            ViewData["errorText"] = errorText;

            return View();
        }

        /// <summary>
        /// 未找到页面
        /// </summary>
        /// <returns></returns>
        [NoPurviewFilter()]
        public ActionResult Error404()
        {
            //将异常修改为208
            Response.StatusCode = 208;
            return View();
        }
    }
}
